# -*- coding: utf-8 -*-
import math

def unpack_or_dup(t):
    """ Unpack the parameter if it's a 2-uple or duplicate it.
    """
    try:
        t1, t2 = t
        return (t1, t2)
    except TypeError:
        return (t, t)

def multiple(num, multiplier, floor=True):
    n = float(num) / multiplier
    if floor:
        n = math.floor(n)
    else:
        n = math.ceil(n)

    return int(n) * multiplier




